package com.mdp.tpa.pay.wxpay.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class RedisCacheLock {

    Log logger= LogFactory.getLog(this.getClass());

    @Autowired
    private StringRedisTemplate redisTemplate;

    public void setKeyValueTimeOut(String key,String value,Long minutes){
        //设置值
        redisTemplate.opsForValue().set(key,value,minutes,TimeUnit.MINUTES);

    }

    public String getKey(String key){
        //获取值
        return redisTemplate.opsForValue().get(key);
    }

    public boolean containKey(String key){
        return redisTemplate.opsForValue().getOperations().hasKey(key);
    }
}
